<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/20 15:19
 */

namespace module\chat\front\form;

use module\chat\enum\RoleEnum;
use module\chat\model\Category;
use mof\enum\StatusEnum;
use mof\Model;
use mof\utils\ElementData;

class VisroleForm extends AssistantForm
{
    protected function elements(Model $model = null): array
    {
        return [
            [
                "label"   => "角色分类",
                "prop"    => "category_id",
                "value"   => $model['category_id'] ?? '',
                "type"    => "select",
                "options" => ElementData::make(Category::getListByType(RoleEnum::VISROLE->value))
                    ->toSelectOptions('name', 'id')
            ],
            [
                "label" => "角色名称",
                "prop"  => "name",
                "value" => $model['name'] ?? '',
            ],
            [
                "label" => "角色简介",
                "prop"  => "intro",
                "value" => $model['intro'] ?? '',
            ],
            [
                "label" => "角色头像",
                "prop"  => "icon",
                "value" => $model['icon'] ?? '',
                "type"  => "upload:image"
            ],
            [
                "label" => "角色描述",
                "prop"  => "config.system",
                "type"  => "textarea",
                "value" => $model['config']['system'] ?? '',
                "rows"  => 4,
            ],
            [
                "label" => "开场白",
                "prop"  => "config.welcome",
                "type"  => "textarea",
                "value" => $model['config']['welcome'] ?? '',
                "rows"  => 4,
                "intro" => '进入对话页面时显示的欢迎语',
            ],
            [
                "label" => "例子",
                "prop"  => "config.sample",
                "type"  => "textarea",
                "value" => $model['config']['sample'] ?? '',
                "rows"  => 4,
                "intro" => '每行一个例子',
            ],
            [
                "label"   => "状态",
                "prop"    => "status",
                "value"   => $model['status'] ?? 1,
                "type"    => "select",
                "options" => StatusEnum::toDict()->toElementData()->toSelectOptions(),
                "colSpan" => 12
            ],
            [
                "label"   => "排序",
                "prop"    => "listorder",
                "value"   => $model['listorder'] ?? 0,
                "colSpan" => 12
            ],
        ];
    }
}